package com.czm.art_light.patterns.chainOfResponsibility.impl;

import com.czm.art_light.constant.CommonConsts;
import com.czm.art_light.context.UserActionStrategyContext;
import com.czm.art_light.manager.mq.producer.AmqpMsgProducer;
import com.czm.art_light.param.request.ArtWorkESReqDto;
import com.czm.art_light.param.request.UserActionReqDto;
import com.czm.art_light.patterns.chainOfResponsibility.UserActionHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 发送通知处理器,更新ES中的艺术作品统计信息
 */
@Component
public class SendNotificationHandler implements UserActionHandler {
    @Autowired
    private AmqpMsgProducer amqpMsgProducer;

    @Autowired
    private UserActionStrategyContext userActionStrategyContext;

    @Override
    public void handle(UserActionReqDto userActionReqDto) {
        // 根据行为类型发送通知
//        userActionStrategyContext.getSaveOrderStrategy(userActionReqDto.getActionType().getValue()).pushMessage(userActionReqDto);
        // 发送消息，更新ES中艺术作品的统计信息
        amqpMsgProducer.sendArtworkChangeMsg(new ArtWorkESReqDto(userActionReqDto.getWorkId(),false));
    }


    @Override
    public Integer sort() {
        return CommonConsts.ChainSortEnum.SORT_3.getSort();
    }
}